package cn.stazxr;

import javax.swing.*;
import java.awt.*;

/**
 * Package: cn.stazxr
 *
 * @Author: stazxr
 * @Create: 2023/12/10
 * @Version: v1.0
 **/
public class SwingTest {
    public static void main(String[] args) {
        JFrame frame = new JFrame("我是标题");
        frame.setBounds(500, 300, 500, 300);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLayout(null);

        JButton button = new JButton("我是按钮");
        button.setBounds(10, 10, 100, 30);
        button.setToolTipText("这个按钮是用来解决你毕设的！");
        frame.add(button);

        Button awtButton = new Button("I am a awt button");
        awtButton.setBounds(10, 50, 100, 30);
        frame.add(awtButton);

        JMenuBar bar = new JMenuBar();
        JMenu menu = new JMenu("我是菜单");
        JMenuItem item = new JMenuItem("我是一号选项");
        item.setAccelerator(KeyStroke.getKeyStroke("ctrl A"));
        item.addActionListener(e -> System.out.println("我被点击了"));
        menu.add(item);
        menu.add(new JMenuItem("我是二号选项"));
        menu.add(new JMenuItem("我是三号选项"));
        bar.add(menu);

        frame.setJMenuBar(bar);
        frame.setVisible(true);
    }
}
